//
//  VCPhotoNextViewController.m
//  NBTripe
//
//  Created by 陈曦 on 16/1/16.
//  Copyright © 2016年 Vicki. All rights reserved.
//

#import "VCPhotoNextViewController.h"
#import "VCPhotoCollectionViewCell.h"


@interface VCPhotoNextViewController ()<UICollectionViewDelegate, UICollectionViewDataSource>
@property (nonatomic,strong) UICollectionView *collectionView;
@property (nonatomic,strong) UICollectionViewFlowLayout *flowLayout;
@end

@implementation VCPhotoNextViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];
//    self.title = [self.arr[self.index] title];
    self.flowLayout = [[UICollectionViewFlowLayout alloc]init];
    // item的最小行间距
    _flowLayout.minimumLineSpacing = 0;
    // item的最小列间距
    _flowLayout.minimumInteritemSpacing = 0;
    // 滑动方向
    _flowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    self.collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0 ,  0, WIDTH, self.view.height - 110 ) collectionViewLayout:self.flowLayout];
    // item的大小
    [self.collectionView setContentOffset:CGPointMake(WIDTH*_index, 0)];
    self.flowLayout.itemSize = CGSizeMake(WIDTH, self.collectionView.height);
    
    _collectionView.delegate = self;
    _collectionView.dataSource = self;
    _collectionView.pagingEnabled = YES;
    _collectionView.backgroundColor = [UIColor colorWithRed:250/255.0 green:246/255.0 blue:232/255.0 alpha:1];
    [self.collectionView registerClass:[VCPhotoCollectionViewCell class] forCellWithReuseIdentifier:@"VCPhotoCollectionViewCell"];
    [self.view addSubview:self.collectionView];
    
    // Do any additional setup after loading the view.
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return self.arr.count;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    
    VCPhotoCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"VCPhotoCollectionViewCell" forIndexPath:indexPath];
    cell.name = [self.arr[indexPath.row] photo];
    
    return cell;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
